<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="jquery.min.js"></script>
</head>

<body>
    <script>
        let p1 = new Promise(function(resolve, reject) {
            $.ajax({
                url: "data/arr.txt",
                datatype: "json",
                success: function(arr) {
                    resolve(arr)
                },
                error: function(err) {
                    reject(err)
                }
            })
        })

        let p2 = new Promise(function(resolve, reject) {
            $.ajax({
                url: "data/json.json",
                datatype: "json",
                success: function(arr) {
                    resolve(arr)
                },
                error: function(err) {
                    reject(err)
                }
            })
        })

        // let p = new Promise(function(resolve, reject) {
        //     $.ajax({
        //         url: "data/json.json",
        //         datatype: "json",
        //         data: {
        //             res1[1],
        //             res2[1]
        //         }
        //         success: function(arr) {
        //             resolve(arr)
        //         },
        //         error: function(err) {
        //             reject(err)
        //         }
        //     })
        // })
        Promise.all([p1, p2]).then(function(arr) {
            console.log(arr);
            let [res1, res2] = arr;
            alert("全部完成");
            console.log(res1, res2);
        }, function(err) {
            alert("至少有一个不成功")
        })
    </script>
</body>

</html>